﻿using GTSDemo.ViewModels;
using GTSDemo.Views;
using Prism.Ioc;
using Prism.Mvvm;
using Prism.Unity;
using System;
using System.Reflection;
using System.Windows;

namespace GTSDemo
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : PrismApplication
    {

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            containerRegistry.RegisterDialog<MessageDialog, MessageDialogVM>();
        }
        protected override void ConfigureViewModelLocator()
        {
            base.ConfigureViewModelLocator();
            ViewModelLocationProvider.SetDefaultViewTypeToViewModelTypeResolver((viewType) =>
            {
                var viewModelName = $"{viewType.Namespace.Replace("Views", "ViewModels")}.{viewType.Name}VM";
                return Type.GetType(viewModelName);
            });
        }

        protected override Window CreateShell()
        {            
            return Container.Resolve<MainWindow>();
        }
    }
}
